import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const mobileStore = new Vuex.Store({
  state: {
    mobile: null,
    userName: null,
    vehicleCore: {},
    carSearch: {},
    country: {},
    vehiclePrices: {},
    rateAmount: {},
    rateAmountType: '',
    suppliersData: {},
    carLocation: []
  },
  getters: {
    getMobile(state) {
      return state.mobile
    },
    getUserName(state) {
      return state.userName
    },
    getVehicleCore(state) {
      return state.vehicleCore
    },
    getCarSearch(state) {
      return state.carSearch
    },
    getCountry(state) {
      return state.country
    },
    getVehiclePrices(state) {
      return state.vehiclePrices
    },
    getRateAmount(state) {
      return state.rateAmount
    },
    getRateAmountType(state) {
      return state.rateAmountType
    },
    getSuppliersData(state) {
      return state.suppliersData
    },
    getCarLocation(state) {
      return state.carLocation
    }
  },
  mutations: {
    setMobile(state, mobile) {
      state.mobile = mobile
    },
    setUserName(state, userName) {
      state.userName = userName
    },
    setVehicleCore(state, vehicleCore) {
      state.vehicleCore = vehicleCore
    },
    setCarSearch(state, carSearch) {
      state.carSearch = carSearch
    },
    setCountry(state, country) {
      state.country = country
    },
    setVehiclePrices(state, vehiclePrices) {
      state.vehiclePrices = vehiclePrices
    },
    setRateAmount(state, rateAmount) {
      state.rateAmount = rateAmount
    },
    setRateAmountType(state, rateAmountType) {
      state.rateAmountType = rateAmountType
    },
    setSuppliersData(state, suppliersData) {
      state.suppliersData = suppliersData
    },
    setCarLocation(state, carLocation) {
      state.carLocation = carLocation
    }
  },
  actions: {
    setMobile({commit}, mobile) {
      commit('setMobile', mobile)
    },
    setUserName({commit}, userName) {
      commit('setUserName', userName)
    },
    setVehicleCore({commit}, vehicleCore) {
      commit('setVehicleCore', vehicleCore)
    },
    setCarSearch({commit}, carSearch) {
      commit('setCarSearch', carSearch)
    },
    setCountry({commit}, country) {
      commit('setCountry', country)
    },
    setVehiclePrices({commit}, vehiclePrices) {
      commit('setVehiclePrices', vehiclePrices)
    },
    setRateAmount({commit}, rateAmount) {
      commit('setRateAmount', rateAmount)
    },
    setRateAmountType({commit}, rateAmountType) {
      commit('setRateAmountType', rateAmountType)
    },
    setSuppliersData({commit}, suppliersData) {
      commit('setSuppliersData', suppliersData)
    },
    setCarLocation({commit}, carLocation) {
      commit('setCarLocation', carLocation)
    }
  },
  plugins: [createPersistedState({
    storage: window.sessionStorage
  })]
})

export default mobileStore
